var element = layui.element,layer = layui.layer
    ,table = layui.table
    ,$ = layui.jquery,tree = layui.tree;
var datas = [{
    title: '客户属性'
    ,id: 1
    ,field: 'name1'
    ,checked: true
    ,spread: true
    ,children: [{
        title: '客户类型'
        ,href:"views/jsp/SystemCenter/tpl/customertype.jsp"
        ,field: ''
    },{
        title: '供应商类型'
        ,id: 20
        ,href:"views/jsp/SystemCenter/tpl/customertype.jsp"
        ,field: ''
    },{
        title: '客户来源'
        ,href:"views/jsp/SystemCenter/tpl/customersource.jsp"
        ,field: ''
    },{
        title: '主营产品'
        ,href:"views/jsp/SystemCenter/tpl/customersource.jsp"
        ,field: ''
    }]
},{
    title: '基础信息'
    ,id: 2
    ,field: 'name2'
    ,children: [{
        title: '运输方式'
        ,href:"views/jsp/SystemCenter/tpl/customersource.jsp"
        ,field: ''
    },{
        title: '国家地区'
        ,href:"views/jsp/SystemCenter/tpl/countriesregions.jsp"
        ,field: ''
    },{
        title: '港口'
        ,href:"views/jsp/SystemCenter/tpl/port.jsp"
        ,field: ''
    }]
}, {
    title: '商品信息'
    , id: 3
    , field: 'name3'
    , children: [{
        title: 'HS编码'
        , href: "views/jsp/SystemCenter/tpl/HScode.jsp"
        , field: ''
    }, {
        title: '数量单位'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '重量单位'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }]
}, {
    title: '仓库维护'
    , id: 4
    , field: 'name4'
    , children: [{
        title: '主仓库维护'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '资源/样品维护'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }]
}, {
    title: '结算相关'
    , id: 5
    , field: 'name5'
    , children: [{
        title: '发票类型'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '币种'
        , href: "views/jsp/SystemCenter/tpl/currency.jsp"
        , field: ''
    },{
        title: '付款方式'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '价格术语'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    },{
        title: '付款类型'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '收款类型'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    },{
        title: '费用类型'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }]
}, {
    title: '其它杂项'
    , id: 6
    , field: 'name6'
    , children: [{
        title: '业务模式'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '账期'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    },{
        title: '报关方式'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }, {
        title: '文件类型'
        , href: "views/jsp/SystemCenter/tpl/customersource.jsp"
        , field: ''
    }]
}];
var searchName="";
getData();
var trs=tree.render({
    elem: '#cictionary' //默认是点击节点可进行收缩
    ,data: datas
    ,click: function(obj){
        if(obj.data.href!=""){
            $('#iframeid').css("height",window.innerHeight-100+"px")
            $('#iframeid').attr("src",obj.data.href+"?dl="+obj.data.type+"&xl="+obj.data.lx);
        }
    }
    ,id: 'dictionaryid'
});
$("#searchs").on("click",function () {
    searchName = $('#cictionaryname').val();
    getData();
    trs.config.data =datas;
    tree.reload("dictionaryid",{data:datas});

   // layer.msg("搜索"+cictionaryname);
    return false;
})
function getData() {
    $.ajax({
        type : 'GET',
        data:{"name":searchName},
        url : 'dictionary2/queryAlllx',
        async:false,
        success : function (da) {
            if(da.status==200 ){
                datas=da.data;
            }
        },
        error: function(data) {
            layer.msg("初始化失败!");
        }
    });
}